package cn.sciento.farm.devicemanager.common.constant;

public enum InverterError {
    INVERTER_UNIT_PROTECTION(1,"逆变单元保护"),
    ACCELERATED_OVERCURRENT(2,"加速过电流"),
    DECELERATION_OVERCURRENT(3,"减速过电流"),
    CONSTANT_SPEED_OVERCURRENT(4,"恒速过电流"),
    ACCELERATED_OVERVOLTAGE(5,"加速过电压"),
    DECELERATION_OVERVOLTAGE(6,"减速过电压"),
    CONSTANT_SPEED_OVERVOLTAGE(7,"恒速过电压"),
    CONTROL_POWER_FAILURE(8,"控制电源故障"),
    UNDERVOLTAGE_FAULT(9,"欠压故障"),
    INVERTER_OVERLOAD(10,"变频器过载"),
    MOTOR_OVERLOAD(11,"电机过载"),
    OUTPUT_PHASE_MISSING(13,"输出缺相"),
    MODULE_OVERHEATING(14,"模块过热"),
    EXTERNAL_EQUIPMENT_FAILURE(15,"外部设备故障"),
    COMMUNICATION_FAILURE(16,"通讯故障"),
    CONTACTOR_FAILURE(17,"接触器故障"),
    CURRENT_DETECTION_FAULT(18,"电流检测故障"),
    MOTOR_TUNING_FAULT(19,"电机调谐故障"),
    EEPROM_READ_WRITE_FAILURE(21,"EEPROM读写故障"),
    FREQUENCY_CONVERTER_HARDWARE_FAULT(22,"变频器硬件故障"),
    GROUND_SHORT_CIRCUIT_FAULT(23,"对地短路故障"),
    ACCUMULATED_RUNNING_TIME_TO_FAILURE(26,"累计运行时间到达故障"),
    ACCUMULATED_POWER_ON_TIME_TO_FAILURE(29,"累计上电时间到达故障"),
    WAVE_BY_WAVE_CURRENT_LIMITING_FAULT(40,"逐波限流故障"),
    RUNTIME_SWITCHING_MOTOR_FAILURE(41,"运行时切换电机故障"),
    HIGH_PRESSURE_ANOMALY(60,"高压异常"),
    LOW_PRESSURE_ANOMALY(61,"低压异常"),
    ABNORMAL_WATER_SHORTAGE(63,"缺水异常"),
    UNKNOWN_ERROR(100,"未知错误");


    private Integer code;
    private String message;

    InverterError(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public static InverterError match(Integer code) {
        for (InverterError error : InverterError.values()) {
            if (error.getCode().equals(code)) {
                return error;
            }
        }
        return UNKNOWN_ERROR;
    }
}
